package ru.amse.ilyin.gui;

import javax.swing.ButtonGroup;
import javax.swing.JToggleButton;
import javax.swing.JToolBar;

import ru.amse.ilyin.gui.actions.ClassDiagramAction;
import ru.amse.ilyin.gui.actions.PackageDiagramAction;
import ru.amse.ilyin.gui.actions.TestAction;

class ToolbarFactory {
	/**
	 * Creates application toolbar.
	 * 
	 * @param window application main window
	 * @return toolbar
	 */
	public static JToolBar createToolbar(MainWindow window) {
		final JToolBar result = new JToolBar();
		
		addChangeDiagramButtons(result, window);
		
//		result.add(new JSeparator(SwingConstants.VERTICAL));
		
		result.add(new TestAction());
		result.add(new TestAction());
		result.add(new TestAction());
		
		return result;
	}

	private static void addChangeDiagramButtons(
			JToolBar result, 
			MainWindow window
	) {
		final JToggleButton button1 = new JToggleButton(
				new PackageDiagramAction(window));
		button1.setSelected(true);
		final JToggleButton button2 = new JToggleButton(
				new ClassDiagramAction(window));
		
		final ButtonGroup group = new ButtonGroup();
		group.add(button1);
		group.add(button2);
		
		result.add(button1);
		result.add(button2);
	}
}
